#!/bin/sh
':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"

var fs = require("fs"); 

var output = process.argv[process.argv.length - 1]; 
var input = process.argv.splice(2, process.argv.length - 3); 

if(input.length == 0) {
	console.log("No input files! Exiting.");
	return; 
} 

//console.log(input+" > "+output); 

var templates = {}; 
input.map(function(x){
	var name = x.replace(/^.*src\//, ""); 
	templates[name] = String(fs.readFileSync(x)); 
}); 

var code = ""; 
Object.keys(templates).map(function(k){
	code += "JUCI.template(\""+k+"\", "+JSON.stringify(templates[k].replace(/\t/gi, ""))+");"; 
}); 

fs.writeFileSync(output, code); 
